Ext.ns('net.autodata.compare.data');
(function() {

    var Proxy = Ext.extend(Ext.data.DataProxy, {

        constructor: function() {
            var api = {};
            api[Ext.data.Api.actions.read] = true;
            Proxy.superclass.constructor.call(this, { api: api });
        },

        doRequest: function(action, rs, params, reader, callback, scope, arg) {
            // No implementation for CRUD in MemoryProxy.  Assumes all actions are 'load'

            //Grab the base vehicle and competitors from Session

            var session = net.autodata.Session.getInstance();
            var vehicles = session.vehicles;

            var rows = [];

            vehicles.eachCompetitor(function(competitor) {
                rows.push(competitor ? competitor : {});
            });

            var data = {
                rows: rows
            };

            try {
                result = reader.readRecords(data);
            } catch (e) {
                // @deprecated loadexception
                this.fireEvent("loadexception", this, null, arg, e);

                this.fireEvent('exception', this, 'response', action, arg, null, e);
                callback.call(scope, null, arg, false);
                return;
            }
            callback.call(scope, result, arg, true);
        }
    });

    net.autodata.compare.data.CompetitorVehiclesSessionProxy = Proxy;

})();